/*******************************************************************************
New Unit Technologies, a division of DBI, LLC.

Created for CS450 at West Virginia University, Fall 2003

Developers:	Matthew Bradley
		Andrew Lowery
		Richard Paletta
		J. Ryan Sigler

File name: pcb.h
*******************************************************************************/
/*******************************************************************************
Change log: 9/30/03 - Rich created header
	    10/1/03 - Ryan adds queue structure to header
	    10/2/03 - Ryan debugs PCB and Queue structures
	    10/3/03 - Ryan edits function prototypes
            10/4/03 - Rich and Ryan add and edit function prototypes
	    10/5/03 - Rich and Drew add comments
*******************************************************************************/
#ifndef PCB_H
#define PCB_H

#define APP 0
#define SYS 1
#define RUNNING 0
#define READY 1
#define BLOCKED 2
#define SUS_READY 3
#define SUS_BLOCKED 4

typedef struct PCB
{
	char 	name[9];   			//Unique Process name
	int 	pclass;				//Process Class (either APP or SYS)
	int 	priority;   			//Process priority -128 to 127
	int 	state;				//Process state (RUNNNING READY BLOCKED SUS_READY SUS_BLOCKED)

	//attribute links

	unsigned char *stack;				//Process stack area. dynamically allocated to at least 1K
	int 	mem_size;			//Size of process memory
	unsigned char *load;				//Starting address of mem area where process should be loaded
	unsigned char *exe;			   	//Address at which execution should begin
	unsigned char *top;         //The top of the stack where all the context information is located

	//pointers for queue list

	struct PCB 	*next;			//points to next PCB in data structure
	struct PCB 	*prev;			//points to the previous PCB in data structure

}PCB;


typedef struct	queue{
	int  	count;
	PCB     *front;				//points to beginning of queue
	PCB     *back;               		//points to end of queue

}queue;


//queue function prototypes

void initialize (queue *newqueue);
void insert(PCB *new_pcb, queue *current_queue);
void pinsert(PCB *new_pcb, queue *current_queue);
void removepcb (PCB *old_pcb, queue *current_queue);
void traversequeue(queue *current_queue);
PCB  *findpcb(char pcb_to_find[]);

//PCB function prototypes

PCB *newPCB(void);
void setupPCB( PCB *newPCB, char newname[], int newpclass, int newpriority, int memory, int offset);
void killPCB(PCB *pcb_ptr);

#endif








